package main

import (
	"gitee.com/sunliang711/locker-control/server/types"
	"github.com/fatih/color"
	"log"
	"net"
)

func main() {
	LockerOpen()
	LockerStatus()
	color.New(color.FgBlue).Printf("blue font")
	color.Cyan("Prints text in cyan.")
	color.Blue("Prints %s in blue.", "text")
	color.Red("We have red")
	color.Magenta("And many others ..")
	host := "localhost:7000"
	conn, err := net.Dial("tcp", host)
	fatalErr(err)
	defer conn.Close()
	ping := types.NewFrame(types.CmdHeart4G, nil)
	n, err := conn.Write(ping.Bytes())
	if err != nil {
		log.Printf("Write ping msg error: %s", err)
	} else {
		log.Printf("Write ping %d bytes", n)
	}
}

func fatalErr(err error) {
	if err != nil {
		log.Fatal(err)
	}
}
func LockerOpen() {
	defer func() {
		log.SetPrefix("")
	}()
	log.SetPrefix("LockerOpen")
	log.SetFlags(log.LstdFlags)
	log.Println("abc")
	log.Println("def")
}

func LockerStatus() {
	//log.SetPrefix("LockerStatus")
	//log.SetFlags(log.LstdFlags)
	log.Println("aaa")
	log.Println("bbb")
}
